package com.liveinstars.xxl.aspect;

import com.xxl.job.core.log.XxlJobLogger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

/**
 * 异常处理切面
 * Created by guoyanjiang on 2018/5/5.
 */
@Aspect
@Component
public class ExceptionHandlerAspect {

    @AfterThrowing(value = "execution(* com.liveinstars.*.task.*.execute(..))", throwing = "e")
    public void scheduled(JoinPoint point, Throwable e) {
        MethodSignature signature = (MethodSignature) point.getSignature();

        XxlJobLogger.log("schedule error {}", signature.getMethod().getName());
        XxlJobLogger.log(e);
    }

}
